<template>
  <div class="about_block">
    <!-- 左上角的编号，黄色背景 -->
    <div class="about_block__num">{{ id }}</div>
    
    <!-- 四个角的装饰边框（左上角被编号替代） -->
    <div class="corner top_right"></div>
    <div class="corner bottom_right"></div>
    <div class="corner bottom_left"></div>
    
    <!-- 图标区域 -->
    <div class="about_block__ico">
      <img :src="iconUrl" :alt="text" class="svg" />
    </div>
    
    <!-- 文字内容 -->
    <div class="about_block_content">
      <strong>{{ text }}</strong>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue';

// 导入所有图标
import about1 from '@/assets/images/icons/about1.svg';
import about2 from '@/assets/images/icons/about2.svg';
import about3 from '@/assets/images/icons/about3.svg';
import about4 from '@/assets/images/icons/about4.svg';
import about5 from '@/assets/images/icons/about5.svg';
import icon6 from '@/assets/images/icons/Icon-6.svg';

const props = defineProps<{
  id: string;
  icon: string;
  text: string;
}>();

// 图标映射
const iconMap: Record<string, string> = {
  'about1': about1,
  'about2': about2,
  'about3': about3,
  'about4': about4,
  'about5': about5,
  'Icon-6': icon6,
};

// 根据icon名称获取图标URL
const iconUrl = computed(() => {
  return iconMap[props.icon] || '';
});
</script>

<style>
/* 使用全局样式，仅在此组件中添加必要的补充 */
.about_block {
  width: 100%;
  padding: 6rem 4rem 3rem;
  font-size: 1.6rem;
  line-height: 2.8rem;
  color: #828c9f;
  transition: all 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 29rem;
  background-color: transparent;
  overflow: visible;
}

.about_block:hover {
  background-color: #232b39;
  box-shadow: 0 4rem 8rem rgba(17, 23, 36, 0.6);
}

.about_block:hover .corner {
  opacity: 0;
}

.about_block:hover .about_block__ico img {
  opacity: 1;
  transform: scale(1.1);
}

/* 四个角的装饰边框 */
.corner {
  position: absolute;
  width: 3rem;
  height: 3rem;
  transition: all 0.3s ease-in-out;
  opacity: 1;
  z-index: 1;
}

.corner.top_right {
  right: 0;
  top: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.corner.bottom_right {
  bottom: -1px;
  right: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.corner.bottom_left {
  left: -1px;
  bottom: -1px;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

/* 编号 - 左上角黄色背景 */
.about_block__num {
  background-color: #e58707;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  width: 3rem;
  height: 3rem;
  left: 0;
  top: 0;
  font-size: 1.4rem;
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  z-index: 99;
  line-height: 1;
}

/* 图标区域 */
.about_block__ico {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3.5rem;
  flex: 1;
}

.about_block__ico img {
  max-width: 6.4rem;
  max-height: 6.4rem;
  width: auto;
  height: auto;
  transition: all 0.3s ease-in-out;
  opacity: 0.6;
}

/* 文字内容 */
.about_block_content {
  text-align: center;
  font-size: 1.6rem;
  line-height: 2.8rem;
  color: #828c9f;
  flex-shrink: 0;
}

.about_block_content strong {
  color: #fff;
  font-weight: 600;
}

/* 响应式设计 */
@media screen and (max-width: 1499px) {
  .about_block {
    padding: 4.5rem 1.5rem 2rem;
    line-height: 2rem;
    height: 22rem;
  }

  .about_block__ico {
    margin-bottom: 2rem;
  }
  
  .about_block__ico img {
    max-width: 5rem;
    max-height: 5rem;
  }
}

@media screen and (max-width: 1199px) {
  .about_block {
    font-size: 1.4rem;
  }

  .about_block__ico img {
    max-width: 5rem;
    max-height: 5rem;
  }

  .about_block__ico {
    margin-bottom: 1.5rem;
  }
}

@media screen and (max-width: 600px) {
  .about_block {
    width: 100%;
  }
}

@media screen and (max-width: 420px) {
  .about_block {
    width: 100%;
    height: 20rem;
  }
}
</style>